/**
 * 
 */
package com.geekteam.manga.sync;

import android.content.Intent;

import com.geekteam.manga.Utils.Constant;
import com.geekteam.manga.Utils.LogUtils;
import com.geekteam.manga.Utils.MangaApplication;
import com.geekteam.manga.Utils.Constant.API;

/**
 * @author MtRol
 * 
 */
public class SyncHelper {
	private static final String TAG = LogUtils.makeLogTag(SyncHelper.class);
	private static SyncHelper mIntance;

	public static SyncHelper getInstance() {
		if (mIntance == null) {
			synchronized (SyncHelper.class) {
				if (mIntance == null) {
					mIntance = new SyncHelper();
				}
			}
		}

		return mIntance;
	}

	private SyncHelper() {
	}

	public void performGetListManga(int type, String lastId, int pageSize) {
		LogUtils.LOGI(TAG, "get list Manga. lastId: " + lastId);
		Intent intent = new Intent(MangaApplication.getInstance(),
				SyncService.class);
		intent.putExtra(API.TYPE, type);
		intent.putExtra(API.LAST_ID, lastId);
		intent.putExtra(API.PAGESIZE, pageSize);
		intent.putExtra(API.TYPE_REQUEST, Constant.TYPE_REQUEST_LISTMANGA);
		MangaApplication.getInstance().startService(intent);
	}

	public void performGetDetailManga(String mangaId, int lastChap, int pageSize) {
		LogUtils.LOGI(TAG, "get detail Manga:  " + mangaId);
		Intent intent = new Intent(MangaApplication.getInstance(),
				SyncService.class);
		intent.putExtra(API.MANGA_ID, mangaId);
		intent.putExtra(API.LAST_CHAP, lastChap);
		intent.putExtra(API.PAGESIZE, pageSize);
		intent.putExtra(API.TYPE_REQUEST, Constant.TYPE_REQUEST_DETAIL);
		MangaApplication.getInstance().startService(intent);
	}
}
